//
//  NFSShopPlanViewController.m
//  NeedForSpeed
//
//  Created by 王国强 on 15/10/23.
//  Copyright © 2015年 Avenger. All rights reserved.
//

#import "NFSShopPlanViewController.h"

#import "BaseHeader.h"

#import "NFSWCarsView.h"

@interface NFSShopPlanViewController ()

@property(nonatomic,strong)UITextField *priceTextField ;

@property(nonatomic)NFSWCarsView *rightTableView;
@end

@implementation NFSShopPlanViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"购车计算器";
    [self.view setBackgroundColor:[UIColor colorWithRed:250./255. green:250./255. blue:250./255 alpha:1]];
    [self createMainView];
    [self createRigtView];
}

- (void)createMainView
{
    UILabel *hintLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, 40)];
    [hintLabel setText:@"选择车型或输入价格"];
    [self.view addSubview:hintLabel];
    
    
    UITextField *chooseTextField = [[UITextField alloc]initWithFrame:CGRectMake(0, 104, SCREEN_WIDTH, 40)];
    [chooseTextField setPlaceholder:@"选择车型"];
    [self.view addSubview:chooseTextField];
    [chooseTextField setBackgroundColor:[UIColor whiteColor]];
    UIButton *chooseButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [chooseButton setFrame:CGRectMake(0, 40 + 64, SCREEN_WIDTH, 40)];
    [chooseButton addTarget:self action:@selector(chooseButton) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:chooseButton];
    
    _priceTextField = [[UITextField alloc]initWithFrame:CGRectMake(0, 80 + 64, SCREEN_WIDTH, 40)];
    [_priceTextField setBackgroundColor:[UIColor whiteColor]];
    [_priceTextField setPlaceholder:@"输入价格"];
    [self.view addSubview:_priceTextField];
    [_priceTextField setKeyboardType:UIKeyboardTypeNumberPad];
    UIButton *countButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [countButton setFrame:CGRectMake(10, 224, SCREEN_WIDTH - 20, 40)];
    [countButton setTitle:@"计 算" forState:UIControlStateNormal];
    [countButton setBackgroundColor:[UIColor blueColor]];
    [countButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [countButton addTarget:self action:@selector(countButton) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:countButton];
}
- (void)countButton
{
    [_priceTextField resignFirstResponder];
}

- (void)chooseButton
{
    [_rightTableView setFrame:CGRectMake(0, 64, SCREEN_WIDTH *3 / 4, SCREEN_HEIGHT)];
}
- (void)createRigtView
{
    _rightTableView = [[NFSWCarsView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH, 64,SCREEN_WIDTH * 3 / 4 , SCREEN_HEIGHT)];
    [self.view addSubview:_rightTableView];
    
    UISwipeGestureRecognizer *rightTablePush = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(rightPush)];
    [_rightTableView addGestureRecognizer:rightTablePush];
}
- (void)rightPush
{
    [UIView animateWithDuration:0.5 animations:^{
        
        [_rightTableView setFrame:CGRectMake(SCREEN_WIDTH, 64, SCREEN_WIDTH * 3 / 4, SCREEN_HEIGHT)];
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
